<?php
/**
 * Data tansfer object for nameserver information
 *
 *
 * @author Ralph de Boom <php5-sidnepp@mijndomein.nl>
 * @author Peter Keizer <php5-sidnepp@mijndomein.nl>
 * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License v3
 * @copyright http://www.mijndomein.nl/
 * @version 0.5
 * @link http://php5-sidnepp.svn.sourceforge.net/viewvc/php5-sidnepp/trunk/dev/docs/index.html
 * @see http://php5-sidnepp.svn.sourceforge.net/viewvc/php5-sidnepp/trunk/dev/docs/php5-sidnepp/SidnNameserverInfo.html
 * @package php5-sidnepp
 */

class SidnNameserverInfo
{
	/**
	 * Holds the hostname of the nameserver
	 * @var <string>
	 */
	private $hostname;

	/**
	 * Holds the IP address of the nameserver
	 * @var <string>
	 */
	private $ipaddress;

	/**
	 * Holds the IP address version of the nameserver
	 * @var <string>
	 */
	private $ipaddressVersion;

	/**
	 * Holds the status of the nameserver as provided by SIDN nameserver info request
	 * @var <string>
	 */
	private $nameserverStatus;
	
	/**
	 *
	 * @param <string> $hostname
	 * @param <string> $ipaddress
	 * @param <string> $nameserverStatus
	 * @todo support multiple IP addresses
	 */
	public function  __construct(
		$hostname,
		$ipaddress = null,
		$nameserverStatus = null
		)
	{
		$this->setHostname($hostname);
		$this->setIpaddress($ipaddress);
		$this->setNameserverStatus($nameserverStatus);
	}

	// getters
	public function getHostname()
	{
		return $this->hostname;
	}

	public function getIpaddress()
	{
		return $this->ipaddress;
	}

	public function getIpaddressVersion()
	{
		return $this->ipaddressVersion;
	}
	
	public function getNameserverStatus()
	{
		return $this->nameserverStatus;
	}

	// setters
	public function setHostname($hostname)
	{
		$this->hostname = $hostname;
	}

	public function setIpaddress($ipaddress)
	{
		if( filter_var( $ipaddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
		{
			$this->ipaddressVersion = SidnEppApi::IP_V6;
			$this->ipaddress        = $ipaddress;
		}
		else if( filter_var( $ipaddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
		{
			$this->ipaddressVersion = SidnEppApi::IP_V4;
			$this->ipaddress        = $ipaddress;
		}
		else
		{
			$this->ipaddress = null;
		}
	}
	
	public function setNameserverStatus($nameserverStatus)
	{
		$this->nameserverStatus = $nameserverStatus;
	}
}
